package com.mcflywzx.airhockey.objects;

import java.util.List;

import com.mcflywzx.airhockey.data.VertexArray;
import com.mcflywzx.airhockey.objects.ObjectBuilder.DrawCommand;
import com.mcflywzx.airhockey.objects.ObjectBuilder.GeneratedData;
import com.mcflywzx.airhockey.programs.ColorShaderProgram;
import com.mcflywzx.airhockey.util.Geometry.Cylinder;
import com.mcflywzx.airhockey.util.Geometry.Point;

public class MCylinder extends Cylinder {

	private static final int POSITION_COMPONENT_COUNT = 3;

	private final VertexArray vA;
	private final List<DrawCommand> drawList;

	public MCylinder(Point position, float R, float H, int numPointsAroundPuck) {
		super(position, R, H);
		GeneratedData gD = ObjectBuilder.createCylinder(this, numPointsAroundPuck);

		vA = new VertexArray(gD.vD);
		drawList = gD.drawList;
	}

	public void bindData(ColorShaderProgram cP) {
		vA.setVertexAttribPointer(0, cP.getPositionAttributeLocation(), POSITION_COMPONENT_COUNT, 0);
	}

	public void draw() {
		for(DrawCommand dC : drawList) {
			dC.draw();
		}
	}
}
